 <link rel="stylesheet" type="text/css" media="all" title="Style sheet" href="../skins/css/formstyle.css" />
<script type="text/javascript" src="../js/jquery-1.3.2.js"></script>
<script type="text/javascript" src="../js/tooltip.js"></script>
<script type="text/javascript" src="../js/common.js"></script>
<script type="text/javascript" src="../js/ui.core.js"></script>
<script type="text/javascript" src="../js/ui.dialog.js"></script>
<script type="text/javascript" src="../js/hopdong.js"></script>
<script type="text/javascript" src="../js/hopdong_ct.js"></script>
<script type="text/javascript" src="../js/core.js"></script>
<script type="text/javascript" src="../js/hopdong_add.js"></script>
<script type="text/javascript" src="../js/hopdong_cp.js"></script>
<script type="text/javascript" src="../js/hopdong_tt.js"></script>
<script type="text/javascript" src="../js/xajax_core.js" charset="UTF-8"></script>
	<script type="text/javascript">
  
  	var JSTRAN = {language:{"_LANGCODE":"vi","_YES":"Yes","_NO":"No","_OK":"\u0110\u1ed3ng \u00fd","_CANCEL":"H\u1ee7y b\u1ecf","_PLEASEWAIT":"Please Wait","_FETCHING":"Loading...","_TAKINGBACK":"Taking you back to where you were....","_US_LOGGEDOUT":"B\u1ea1n \u0111\u00e3 tho\u00e1t kh\u1ecfi h\u1ec7 th\u1ed1ng","_LOGOUT":"Logout","_SUBJECT":"Subject","_ADD":"Add","_EDIT":"Edit","_DELETE":"X\u00f3a","_CLOSE":"Close","_SUBMIT":"Submit","_NOPERM":"B\u1ea1n ch\u01b0a \u0111\u01b0\u1ee3c quy\u1ec1n truy c\u1eadp v\u00e0o khu v\u1ef1c n\u00e0y.","_ERRORS":"Errors","_SEARCH":"Search","_ALL":"All","_TITLE":"Title","_OPTIONS":"Options","_LOGIN":"User Login","_USERNAME":"Username: ","_PASSWORD":"Password: ","_SELECT":"Select","_IMAGE":"Image","_SEND":"Send","_ASCENDING":"Ascending order","_DESCENDING":"Descending order","_BACK":"Back","_CONFIRM":"X\u00e1c nh\u1eadn","_GENCRM_URL":"http:\/\/tamnguyen.gencrm.com","_ERROR_OCCURED":"C\u00f3 l\u1ed7i x\u1ea3y ra","URL":"http:\/\/tamnguyen.gencrm.com","_BAN_CHUA_CHON_CLSP":"B\u1ea1n ch\u01b0a ch\u1ecdn ch\u1ee7ng lo\u1ea1i s\u1ea3n ph\u1ea9m","_VAO_LUC":"V\u00e0o l\u00fac","_BAN_CHUA_CHON_SP":"B\u1ea1n ch\u01b0a ch\u1ecdn s\u1ea3n ph\u1ea9m","_BAN_CHUA_NHAP_SO_LUONG":"B\u1ea1n ch\u01b0a nh\u1eadp s\u1ed1 l\u01b0\u1ee3ng","_SO_LUONG_PHAI_LON_HON_KHONG":"S\u1ed1 l\u01b0\u1ee3ng mua ph\u1ea3i l\u1edbn h\u01a1n 0","ALERT_KH_HD":"B\u1ea1n ch\u01b0a ch\u1ecdn kh\u00e1ch h\u00e0ng","_BAN_CHUA_NHAP_SO_TIEN_THU":"B\u1ea1n ch\u01b0a nh\u1eadp s\u1ed1 ti\u1ec1n thu","_BAN_PHAI_NHAP_SO_TIEN_THU_DUONG":"S\u1ed1 ti\u1ec1n thu ph\u1ea3i > 0","_BAN_CHUA_NHAP_SO_TIEN_CHI":"B\u1ea1n ch\u01b0a nh\u1eadp s\u1ed1 ti\u1ec1n chi","_BAN_PHAI_NHAP_SO_TIEN_CHI_DUONG":"B\u1ea1n ph\u1ea3i nh\u1eadp s\u1ed1 ti\u1ec1n chi > 0","_GIA_BAN_PHAI_DUONG":"Gi\u00e1 b\u00e1n ph\u1ea3i >= 0","_VAT_PHAI_LON_HON_HOAC_BANG_KHONG":"Vat nh\u1eadp ph\u1ea3i d\u01b0\u01a1ng!","decimal":",","lamtron":"0","separator":".","DINH_DANG":"1","ngayht":"16\/01\/2013","donhang":0,"view":0,"_MA_HD_CHUA_NHAP":"B\u1ea1n ch\u01b0a nh\u1eadp m\u00e3 h\u1ee3p \u0111\u1ed3ng","_TEN_HOP_DONG_CHUA_NHAP":"B\u1ea1n ch\u01b0a nh\u1eadp t\u00ean h\u1ee3p \u0111\u1ed3ng","_GIA_TRI_HOP_DONG_KHONG_DUOC_RONG":"B\u1ea1n ch\u01b0a th\u00eam chi ti\u1ebft h\u1ee3p \u0111\u1ed3ng","ALERT_KT_HON_BD":"Ng\u00e0y k\u1ebft th\u00fac ph\u1ea3i >= ng\u00e0y b\u1eaft \u0111\u1ea7u","ALERT_DV_TH":"B\u1ea1n ch\u01b0a ch\u1ecdn \u0111\u01a1n v\u1ecb qu\u1ea3n l\u00fd","ALERT_NGUOI_TH":"B\u1ea1n ch\u01b0a ch\u1ecdn ng\u01b0\u1eddi qu\u1ea3n l\u00fd","_SO_TIEN_CHI_PHAI_DUONG":"S\u1ed1 ti\u1ec1n chi ph\u1ea3i l\u1edbn h\u01a1n 0","_MA_HOP_DONG_DA_TON_TAI":"M\u00e3 h\u1ee3p \u0111\u1ed3ng \u0111\u00e3 t\u1ed3n t\u1ea1i","_ALERT_NGAY_CHI_TT_LONHON_NGAY_CHI":"Ng\u00e0y chi th\u1ef1c t\u1ebf ph\u1ea3i >= ng\u00e0y chi","_BAN_CHUA_CHON_NGAY_CHI_THUC_TE":"B\u1ea1n ch\u01b0a ch\u1ecdn ng\u00e0y chi th\u1ef1c t\u1ebf","Hdo_Id":0,"_BAN_CHUA_NHAP_SO_TIEN_TT":"B\u1ea1n ch\u01b0a nh\u1eadp s\u1ed1 ti\u1ec1n thanh to\u00e1n","_SO_TIEN_TT_PHAI_DUONG":"S\u1ed1 ti\u1ec1n thanh to\u00e1n ph\u1ea3i l\u1edbn h\u01a1n 0","_ALERT_NGAY_TT_TT_LONHON_NGAY_CHI":"Ng\u00e0y thanh to\u00e1n th\u1ef1c t\u1ebf ph\u1ea3i >= ng\u00e0y thanh to\u00e1n","_BAN_CHUA_CHON_NGAY_TT_THUC_TE":"B\u1ea1n ch\u01b0a ch\u1ecdn ng\u00e0y thanh to\u00e1n th\u1ef1c t\u1ebf","_BAN_CHUA_NHAP_SO_LAN_NHAC":"B\u1ea1n ch\u01b0a nh\u1eadp s\u1ed1 l\u1ea7n nh\u1eafc","_SO_LAN_NHAC_PHAI_DUONG":"S\u1ed1 l\u1ea7n nh\u1eafc ph\u1ea3i d\u01b0\u01a1ng","_BAN_CHUA_NHAP_NOI_DUNG_NHAC":"B\u1ea1n ch\u01b0a nh\u1eadp n\u1ed9i dung nh\u1eafc","_THANG":"th\u00e1ng","_NAM":"n\u0103m","_ALERT_NGAY_TT_TT_NHOHON_NGAY_HT":"Ng\u00e0y thanh to\u00e1n th\u1ef1c t\u1ebf ph\u1ea3i nh\u1ecf h\u01a1n ho\u1eb7c b\u1eb1ng ng\u00e0y hi\u1ec7n t\u1ea1i!"}}
  	</script>  
    <script src="../js/NumberFormat154.js"></script>
<script type="text/javascript">
function formatNumber(obj){
				var numberFormat = new NumberFormat(obj.value);
				numberFormat.setSeparators(true, '.', ',');
				numberFormat.setPlaces(0);
				obj.value = numberFormat.toFormatted();
				var obj1 = obj.name + '_';
				document.getElementById(obj1).value = numberFormat.toUnformatted();
			}
</script>	
<script >
	function addElement() {

	  var ni = document.getElementById('myDiv');

	  var numi = document.getElementById('theValue');

	  var num = (document.getElementById('theValue').value -1)+ 2;

	  numi.value = num;

	  var newdiv = document.createElement('div');

	  var divIdName = 'my'+num+'Div';

	  newdiv.setAttribute('id',divIdName);
	  newdiv.setAttribute('style','float:left; width:100%');

	  newdiv.innerHTML = '<p><input type="hidden" id="userfile'+num+'" name="sanpham_hinhanh'+num+'" value=""/><img src="" width="50" id="imgdef'+num+'" name="imgdef'+num+'" height="40" style="float:left; border:#CCC 1px solid" /><input type="button" name="button3" value="Up file đính kèm" onclick="JavaScript:window.open(\'core/Upfile.php?Dir=content&amp;form=userfile'+num+'&img=imgdef'+num+'\',\'_upLoad\' ,\'height=220,width=450,resizable=no,scrollbars=yes\')") />&nbsp; <a href="javascript:;" onclick="removeElement(\''+divIdName+'\');">Xóa</a></p>';

	  ni.appendChild(newdiv);

	}
	function removeElement(divNum) {

	  var vl = document.getElementById('theValue');
	  vl.value= vl.value-1;
	  var d = document.getElementById('myDiv');

	  var olddiv = document.getElementById(divNum);

	  d.removeChild(olddiv);

	}
</script>
<script type="text/javascript" src="../tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript">

	// O2k7 skin
	tinyMCE.init({
		// General options
		mode : "textareas",
		theme : "advanced",
		width : "700",
		height : "200",
		skin : "o2k7",
		plugins : "autolink,lists,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,advlist,autosave,visualblocks",

		// Theme options
		theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,bullist,numlist,outdent,indent,sub,sup,link,unlink,formatselect,fontselect,fontsizeselect,forecolor,backcolor",
		theme_advanced_buttons2 : "",
		theme_advanced_buttons3 : "",
		theme_advanced_buttons4 : "",
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "left",
		theme_advanced_statusbar_location : "bottom",
		theme_advanced_resizing : true,
		theme_advanced_path : false, 
		// Example content CSS (should be your site CSS)
		content_css : "css/content.css",

		// Drop lists for link/image/media/template dialogs
		template_external_list_url : "lists/template_list.js",
		external_link_list_url : "lists/link_list.js",
		external_image_list_url : "lists/image_list.js",
		media_external_list_url : "lists/media_list.js",

		

	});
				
/* Default skin */



</script>

<form style="padding:0; margin:0" action="index.php?tn=customers&kh=cohoi_notes" method="post" name="frmAddMessage" enctype="multipart/form-data">

<?php 
	$id=$_GET['id'];
	$sql_hd=mysql_query("select * from contract where id='$id'");
	$rs_hd=mysql_fetch_array($sql_hd)
?>  
		<input type="hidden" name="cohoi_id" value="<?php echo $rs_hd['id'];?>"/>
        <div class="clear" style="height:5px"></div>
        <table class="box-vang" border="0" cellpadding="0" cellspacing="0" width="100%">
          <tbody><tr>
            <td class="t-l" width="8px"></td>
            <td class="t-c"></td>
            <td class="t-r" width="8px"></td>
          </tr>
          <tr class="light">
            <td class="c-l"></td>
            <td class="c-c"><table border="0" cellpadding="0" cellspacing="0" width="100%">
                <tbody><tr class="light">
                  <td class="title-red" colspan="2" align="left">&nbsp;Chi tiết hợp đồng<span style="float:right">Cập nhật cuối: <?php echo date('d/m/Y h:i a',$rs_hd['update_time']);?> </span></td>
                </tr>
               
                <tr><td class="title-red1" colspan="2">Thông tin chung</td></tr>
                <tr class="light">
                  <td width="50%" style="padding:10px">
         			<table width="100%">
                    <tr>
                    	<td width="30%">Mã hợp đồng </td>
                        <td width="70%"><strong><?php echo $rs_hd['code'];?></strong> </td>
                    </tr>
                    <tr>
                    	<td width="30%">Tên hợp đồng</td>
                        <td width="70%"> <strong><?php echo $rs_hd['name'];?></strong></td>
                    </tr>
                    <tr>
                    	<td width="30%">Khách hàng</td>
                        <td width="70%"><strong>
                        	 <?php $sql_kh=mysql_query("select id,name_kh,name_com from customers where id='".$rs_hd['kh_id']."'");
								while($row_kh=mysql_fetch_array($sql_kh))
								{
							?>
							<?php echo $row_kh['name_com']; echo $row_kh['name_kh'];
                                }
                            ?>
                        </strong> </td>
                    </tr>
                    <tr><td width="30%">Đầu mối liên lạc </td>
                        <td width="70%"><strong><?php 
							$sql_dmll2=mysql_query("select id,name from daumoilienlac where id='".$rs_hd['dmll_id']."'");
							while($rs_dmll2=mysql_fetch_array($sql_dmll2))
							{
								echo $rs_dmll2['name'];
							}
						?></strong> </td>
                    </tr>
                  	<tr> 
                    	<td width="30%">Cơ hội bán hàng </td>
                        <td width="70%"><strong><?php 
							$chbh=mysql_query("select id,name from cohoi where id='".$rs_hd['chbh_id']."'");
							while($rs_chbh=mysql_fetch_array($chbh))
							{
								echo $rs_chbh['name'];
							}
						?></strong> </td>
                    </tr>
                    </table> 
                  </td> 
                 <td width="50%" style="padding:10px">
         			<table width="100%"> 
                    <tr>
                    	<td width="30%">Trạng thái hợp đồng</td>
                        <td width="70%"><strong>
						<?php 
							if($rs_hd['trangthai_id']==1){echo 'Đang thực hiện';}
							if($rs_hd['trangthai_id']==2){echo 'Kết thúc';}
							if($rs_hd['trangthai_id']==3){echo 'Đang hoãn';}
							if($rs_hd['trangthai_id']==4){echo 'hủy';}
                        ?>
                        </strong> </td>
                    </tr>
                    <tr>
                    	<td width="30%">ngày ký </td>
                        <td width="70%"> <strong>
						<?php echo $rs_hd['ngayky'];?>
                        </strong> </td>
                    </tr>
                   <tr>
                    	<td width="30%">Ngày bắt đầu </td>
                        <td width="70%">  <strong>
						<?php echo $rs_hd['ngaybatdau'];?>
                        </strong></td>
                    </tr>
                    <tr>
                    	<td width="30%">Ngày kết thúc </td>
                        <td width="70%"><strong>
						<?php echo $rs_hd['ngayketthuc'];?>
                        </strong> </td>
                    </tr>
                    <tr>
                    	<td width="30%">Chiến dịch Marketing </td>
                        <td width="70%"> <strong>	
                            	<?php 
					  	$marketing_id=$rs_hd['marketing_id'];
						$sql_mar=mysql_query("select IDmarketing,Tenchiendich from tb_marketing where IDmarketing='$marketing_id'");
						$rs_mar=mysql_fetch_array($sql_mar);
					
							echo $rs_mar['Tenchiendich'];
					
					  ?>     
                        </strong> </td>
                    </tr>
                    </table> 
                  </td> 
                </tr> 
                
                
                <?php 
					$sql_nkh=mysql_query("
								select services_type_name,services_type_id  from tb_services_type where phanloai_id=15 and services_type_id='".$rs_kh['nguon_kh']."'
					
					");
						$rs_nkh=mysql_fetch_array($sql_nkh);
					$sql_lkh=mysql_query("select services_type_name,services_type_id  from tb_services_type where phanloai_id=16 and 
							services_type_id='".$rs_kh['loai_kh']."'");
							$rs_lkh=mysql_fetch_array($sql_lkh);
					$sql_lv=mysql_query("select services_type_name,services_type_id  from tb_services_type where phanloai_id=18 and services_type_id='".$rs_kh['area']."'");
						$rs_llv=mysql_fetch_array($sql_lv);
				?>
                <tr><td class="title-red1" colspan="2">Chi tiết hợp đồng</td></tr>
                 <tr>
                 	<td colspan="4">             
        				<table width="100%" cellspacing="0" cellpadding="0">
							<tr>
								<td>
                                 <div style="margin-left:10px;margin-right:10px;width:98%;overflow: hidden;" >
                             <?php $sql_dem=mysql_query("select count(*) as so_ban_ghi from hopdong_ct where hd_id='$id'");
							 	$row_dem=mysql_fetch_array($sql_dem);
							 ?>
                            <input type="hidden" id="count_hdct" name="count_hdct" value="<?php echo $row_dem['so_ban_ghi'];?>" />
                            <input type="hidden" id="count_del_hdct" name="count_del_hdct" value="<?php echo $row_dem['so_ban_ghi'];?>" />
                            <input type="hidden" id="table" name="table" value="hop_dong" />
                            <input type="hidden" id="id_table" name="id_table" value="<?php echo $rs_hd['id'];?>" />
                                    <div class="tableHead" style="overflow: hidden;">
                                        <div style="margin-right: 17px;">
                                            <div class="firstCol" style="color:#0070BA;width:2.7%;" ><b>STT</b></div>
                                            <div class="Cols" style="color:#0070BA;width:12%;"><b>Loại sản phẩm</b></div>
                                            <div class="Cols" style="color:#0070BA;width:12%;"><b>Sản phẩm</b></div>
                                            <div class="Cols" style="color:#0070BA;width:8%;"><b>ĐVT</b></div>
                                            <div class="Cols" style="color:#0070BA;width:10%;"><b>Đơn giá</b></div>
                                            <div class="Cols" style="color:#0070BA;width:7%;"><b>Số lượng</b></div>
                                            <div class="Cols" style="color:#0070BA;width:10%;"><b>Cộng</b></div>
                                            <div class="Cols" style="color:#0070BA;width:10%;"><b>VAT</b></div>
                                            <div class="Cols" style="color:#0070BA;width:11%;"><b>Thành tiền</b></div>
                                            <div class="Cols" style="color:#0070BA;float:right;padding-right:10px;"><b>Thao tác</b></div>
                                        </div>
                                    </div>
							<div  style="max-height:300px; width:100%;overflow-y:scroll;z-index: -1;clear: both;">
								<div id="divSelectedNames">
                                <?php $sql_hdct=mysql_query("select * from hopdong_ct where hd_id='$id' order by id asc");
									 
									while($row_hdct=mysql_fetch_array($sql_hdct))
									{
								?>
									<div id="row_sua_<?php echo $row_hdct['id_row'];?>">
                                    
                                        <div id="row_<?php echo $row_hdct['id_row'];?>" style="overflow: hidden;display:block" class="row01">
                                            <div style="width:2.7%;text-align:center;" class="firstCol">
                                               <?php echo $row_hdct['id_row'];?>
                                            </div>
                                            <div style="width:12%;" class="Cols">
                                                <?php  
												$lsp=$row_hdct['loai_sp'];
												$lsp_name=catchinfor($lsp,"services_type_id","services_type_name","tb_services_type");	
												echo $lsp_name;
												?>
                                            </div>
                                            <div style="width:12%;" class="Cols">
                                                <?php  
												$sp=$row_hdct['sanpham'];
												$sp_name=catchinfor($sp,"IDproduct","Namepro","tb_product");	
												echo $sp_name;
												?>
                                            </div>
                                            <div style="width:8%;" class="Cols">
                                                <?php  
												$dv=$row_hdct['donvi'];
												$dv_name=catchinfor($dv,"services_type_id","services_type_name","tb_services_type");	
												echo $dv_name;
												?>
                                            </div>
                                            <div style="width:10%;text-align:right;" class="Cols">
                                                <?php echo $row_hdct['dongia']?>	
                                            </div>
                                            <div style="width:7%;text-align:center;" class="Cols">
                                                <?php echo $row_hdct['soluong']?>		
                                            </div>
                                            <div style="width:10%;text-align:right;" class="Cols">
                                                <?php echo $row_hdct['cong']?>	
                                            </div>
                                            <div style="width:10%;" class="Cols">
                                                <?php echo $row_hdct['vat']?>	
                                            </div>
                                            <div style="width:11%;text-align:right;" class="Cols">
                                                <?php echo $row_hdct['thanhtien']?>	
                                            </div>
                                            <div style="float:right;padding-right: 10px;" class="Cols">
                                                <b><span onclick="change_display('sua_hdct_<?php echo $row_hdct['id_row'];?>');change_display('row_<?php echo $row_hdct['id_row'];?>');document.getElementById('lsp_id_<?php echo $row_hdct['id_row'];?>').focus();" style="color:#FF9028;cursor: pointer;">Sửa</span>&nbsp;<span onclick="delete_hdct(<?php echo $row_hdct['id_row'];?>,'<?php echo $row_hdct['id'];?>','<?php echo $row_hdct['thanhtien']?>','<?php echo $row_hdct['cong']?>','<?php echo $row_hdct['tienvat']?>');" style="color:#FF0000;cursor: pointer;">Xóa</span></b>
                                            </div>
                                           
                                        </div>
                                      
                                        <div style="overflow: hidden;height:30px;display:none;" id="sua_hdct_<?php echo $row_hdct['id_row'];?>" class="row01">
                                            <div style="width:2.7%;text-align:center;" class="firstCol"><?php echo $row_hdct['id_row'];?></div>
                                            <div style="width:12%;" class="Cols">
                                                <select id="lsp_id_<?php echo $row_hdct['id_row'];?>" name="Cls_Id_<?php echo $row_hdct['id_row'];?>" onchange="show_spham(this.value);" style="width:100%;">
                                                    <option value="">Lựa chọn</option>
                                                    <?php 
                                                        $sql_Lsp=mysql_query("select services_type_id,services_type_name,phanloai_id from 
																		tb_services_type where phanloai_id=18");
                                                        while($rs_Lsp=mysql_fetch_array($sql_Lsp))
                                                        {
                                                    ?>
                                                                <option value="<?php echo $rs_Lsp['services_type_id'];?>" <?php if($rs_Lsp['services_type_id']==$lsp){?> selected="selected"<?php }?>>
																<?php echo $rs_Lsp['services_type_name'];?>
                                                                </option>
                                                    <?php }?>		
                                                </select>
                                            </div>
                                            <div id="arr_sp_<?php echo $row_hdct['id_row'];?>" style="width:12%;" class="Cols">
                                                <select onchange="check_gia_vat(this.value,document.getElementById('soluong_1').value,1);" style="width:100%;" id="Sph_Id_<?php echo $row_hdct['id_row'];?>" name="Sph_Id_<?php echo $row_hdct['id_row'];?>">
                                                    <option value="">Lựa chọn</option>
                                                  <?php $sql_sp=mysql_query("select IDproduct,Namepro,services_type_id from tb_product where services_type_id='$lsp'");
												  	while($rs_sp=mysql_fetch_array($sql_sp))
													{
												  ?>  
                                                    <option  value="<?php echo $rs_sp['IDproduct'];?>"<?php if($rs_sp['IDproduct']==$sp){?> selected="selected"<?php }?>><?php echo $rs_sp['Namepro'];?></option>
                                                    <?php }?>
                                                 </select>
                                            </div>
                                            <div style="width:8%;" class="Cols">
                                                <select id="dvt_id_<?php echo $row_hdct['id_row'];?>" name="Dvt_Id_<?php echo $row_hdct['id_row'];?>" style="width:100%;">
                                                    <option value="">Lựa chọn</option>
                                                    <?php $sql_dv=mysql_query("select services_type_id,services_type_name,phanloai_id from  tb_services_type where phanloai_id=23");
                                                        while($rs_dv=mysql_fetch_array($sql_dv))
                                                        {
                                                    ?>
                                                                <option value="<?php echo $rs_dv['services_type_id'];?>" <?php if($rs_dv['services_type_id']==$dv){?> selected="selected"<?php }?>><?php echo $rs_dv['services_type_name'];?></option>
                                                    <?php }?>
                                                </select>
                                            </div>
                                            <div style="width:10%;" class="Cols">
                                                <input type="text" onblur="formatNumber(this.form.giaban_<?php echo $row_hdct['id_row'];?>);tien_hdct(<?php echo $row_hdct['id_row'];?>);" id="giaban_<?php echo $row_hdct['id_row'];?>" onclick="toUnformattedNumber(\'giaban_<?php echo $row_hdct['id_row'];?>\');"  name="giaban_<?php echo $row_hdct['id_row'];?>" value="<?php echo $row_hdct['dongia'];?>" onkeypress="return isNumberKey(event);" style="width:95%;">
                                                <input type="hidden" id="giaban_<?php echo $row_hdct['id_row'];?>_" value="<?php echo $row_hdct['dongia'];?>" name="giaban_<?php echo $row_hdct['id_row'];?>_">
                                                <input type="hidden" id="gia_codinh_<?php echo $row_hdct['id_row'];?>" value="1" name="gia_codinh_<?php echo $row_hdct['id_row'];?>">
                                            </div>
                                            <div style="width:7%;" class="Cols">
                                                <input type="text" onkeyup="tien_hdct(<?php echo $row_hdct['id_row'];?>);" size="30" value="<?php echo $row_hdct['soluong'];?>" id="soluong_<?php echo $row_hdct['id_row'];?>" name="soluong_<?php echo $row_hdct['id_row'];?>" style="width:95%;" onkeypress="return isNumberKey(event);">
                                            </div>
                                            <div style="width:10%;" class="Cols">
                                                <input type="text" value="<?php echo $row_hdct['cong'];?>" id="tong_cdd_<?php echo $row_hdct['id_row'];?>" style="width:95%;" readonly="readonly">
                                                <input type="hidden" value="<?php echo $row_hdct['cong'];?>" name="tong_tien_hdct_<?php echo $row_hdct['id_row'];?>" id="tien_tong_<?php echo $row_hdct['id_row'];?>">
                                            </div>
                                            <div style="width:10%;" class="Cols">
                                                <input type="hidden" value="<?php echo $row_hdct['vat']; ?>" id="vat_dd_<?php echo $row_hdct['id_row'];?>" style="width:95%;" disabled="true">
                                                <input type="hidden" value="<?php echo $row_hdct['tienvat']; ?>" id="tien_vat_<?php echo $row_hdct['id_row'];?>" name="tien_vat_1">
                                                <input type="text" value="<?php echo $row_hdct['vat'];?>" id="vat_<?php echo $row_hdct['id_row'];?>" name="vat_<?php echo $row_hdct['id_row'];?>" onkeyup="tien_hdct(<?php echo $row_hdct['id_row'];?>);" onkeypress="return isNumberKey(event);" style="width:95%;">
                                            </div>
                                            <div style="width:11%;" class="Cols">
                                                <input type="text" value="<?php echo $row_hdct['thanhtien'];?>" id="thanhtien_dd_<?php echo $row_hdct['id_row'];?>" style="width:95%;" readonly="readonly">
                                                <input type="hidden" value="<?php echo $row_hdct['thanhtien'];?>" id="thanhthien_<?php echo $row_hdct['id_row'];?>" name="thanhthien_1">
                                            </div>
                                            <div style="float:right;padding-right: 10px;" class="Cols">
                                                <span style="color:#FF9028;cursor: pointer;" onclick="check_add_hdct(<?php echo $row_hdct['id_row'];?>,1,'<?php echo $row_hdct['thanhtien'];?>','<?php echo $row_hdct['id'];?>','<?php echo $row_hdct['cong'];?>','<?php echo $row_hdct['tienvat']; ?>');"><b>Lưu</b></span>&nbsp;<span onclick="change_display('sua_hdct_<?php echo $row_hdct['id_row'];?>');change_display('row_<?php echo $row_hdct['id_row'];?>');" style="color:#FF0000;cursor: pointer;"><b>Hủy</b></span>
                                            </div>
                                        </div>

						</div>
                         <?php }?> 
								<div class="row01" id="them_hdct" style="overflow: hidden;height:30px;display:none;">
									<div class="firstCol" id="display_count_hdct" style="width:2.7%;text-align:center;"></div>
									<div class="Cols" style="width:12%;">
		<select id="lsp_id_0" name="Cls_Id_0" onChange="show_spham(this.value);" style="width:100%;">
			<option value="">Lựa chọn</option>
            <?php 
				$sql_Lsp=mysql_query("select services_type_id,services_type_name,phanloai_id from tb_services_type where phanloai_id=18");
				while($rs_Lsp=mysql_fetch_array($sql_Lsp))
				{
			?>
						<option value="<?php echo $rs_Lsp['services_type_id'];?>"><?php echo $rs_Lsp['services_type_name'];?></option>
			<?php }?>		
		</select>
									</div>
									<div class="Cols" style="width:15%;"  id="arr_sp_0">
		<select onChange="check_gia_vat(this.value);" name="Sph_Id_0" id="Sph_Id_0" style="width:100%;">
	<option value="">Lựa chọn</option>
	
	</select>
									</div>
									<div class="Cols" style="width:8%;">
		<select id="dvt_id_0" name="Dvt_Id_0" style="width:100%;">
			<option value="">Lựa chọn</option>
            <?php $sql_dv=mysql_query("select services_type_id,services_type_name,phanloai_id from  tb_services_type where phanloai_id=23");
				while($rs_dv=mysql_fetch_array($sql_dv))
				{
			?>
						<option value="<?php echo $rs_dv['services_type_id'];?>" ><?php echo $rs_dv['services_type_name'];?></option>
			<?php }?>
					</select>
									</div>
									<div class="Cols" style="width:10%;" id="price">
		<input type="text" style="width:95%;" onKeyPress="return isNumberKey(event);"  onclick="toUnformattedNumber('giaban_0');" value="" name="giaban_0"  id="giaban_0"  onblur="formatNumber(this.form.giaban_0);tien_hdct(0);" />
		<input type="hidden" name="giaban_0_" value="" id="giaban_0_" />
		<input type="hidden" name="gia_codinh_0" value="0" id="gia_codinh_0" />
									</div>
                                    <div class="Cols" style="width:7%;">
                                        <input onKeyPress="return isNumberKey(event);"  style="width:95%;" type="text" name="soluong_0" id="soluong_0" value="" size="30" onBlur="tien_hdct(0);" />
                                    </div>
                                    <div class="Cols" style="width:10%;">
                                        <input type="text" disabled="true" style="width:95%;" id="tong_cdd_0" />
                                        <input type="hidden" id="tien_tong_0" name="tong_tien_hdct_0" value="0" />
                                    </div>
                                    <div class="Cols" style="width:10%;">
                                        <input type="hidden" disabled="true" style="width:95%;" id="vat_dd_0" />
                                        <input type="hidden" name="tien_vat_0" id="tien_vat_0" value="" />
                                        <input type="text" style="width:95%;" name="vat_0" id="vat_0" onBlur="tien_hdct(0);" value="" onKeyPress="return isNumberKey(event);"  />
                                    </div>
                                    <div class="Cols" style="width:11%;">
                                        <input type="text" disabled="true" style="width:95%;" id="thanhtien_dd_0" />
                                        <input type="hidden" name="thanhthien_0" id="thanhthien_0" value="0" />
                                    </div>
                                    <div class="Cols" style="color:#0070BA;float:right;padding-right: 10px;">
                                        <b><span onClick="check_add_hdct(0,0,0,'',0,0);" style="color:#FF9028;cursor: pointer;">Lưu</span>&nbsp;<span style="color:#FF0000;cursor: pointer;" onClick="huy_them_hdct();">Hủy</span></b>
                                    </div>
							</div>
		</div>
        		<div>
                    <input type="hidden"  name="giatri" id="giatri" value=""/>
					<input type="hidden" name="Gia_Tri" id="giatri_" value=""/>	
                    <input type="hidden"  id="tongchiphi" name="tongchiphi"  value="" />
					<input type="hidden"  name="Tong_Chi_Phi" id="tongchiphi_" value=""/>
                    <input type="hidden"  id="tiendatt" name="tiendatt" size="30" value="" />
					<input type="hidden"  name="Tien_Da_TT" id="tiendatt_" value=""/>
                    <input type="hidden"  id="tienphaitt" name="tienphaitt" size="30" value=""/>
					<input type="hidden"  name="Tien_Phai_TT" id="tienphaitt_" value=""/>
                </div>
				<div style="float:right; margin-top:10px;" id="bt_add_hdct">
			<input type="button" value="Thêm mới" class="blue_add" style="width:auto;" onClick="change_display('them_hdct');counthdct();" />
		</div>
</div>
                            	</td>
                        	</tr>
                    	</table>
                 	</td>
                </tr>
                
                <tr><td class="title-red1" colspan="2">Thông tin tài chính</td></tr>  
                <tr class="light">
                  <td width="50%" style="padding:10px">
         			<table width="100%">
                    <tr>
                    	<td width="30%">Giá trị hợp đồng</td>
                        <td width="70%"> <strong><?php echo $rs_hd['giatri_hd'];?> &nbsp;(VNĐ)</strong></td>
                    </tr>
                    <tr>
                    	<td width="30%">Tổng chi phí </td>
                        <td width="70%"><strong><?php echo $rs_hd['chiphi'];?> &nbsp;(VNĐ)</strong> </td>
                    </tr>
                    </table> 
                  </td> 
                 <td width="50%" style="padding:10px">
         			<table width="100%"> 
                    <tr>
                    	<td width="30%"> Số tiền đã thanh toán</td>
                    	<td width="70%">
                            <strong>
                            <?php echo $rs_hd['da_tt'];?> &nbsp;(VNĐ)
                            </strong>
                        </td>
                    </tr>
                    <tr>
                    	<td width="30%">Số tiền chưa thanh toán </td>
                    	<td width="70%">
                        <strong>
						<?php echo $rs_hd['chua_tt'];?>&nbsp;(VNĐ)
                        </strong>
                        </td>
                    </tr>
                   
                    </table> 
                  </td> 
                </tr> 
                 <tr><td class="title-red1" colspan="2">Thông tin quản lý</td></tr>
                <tr class="light">
                  <td width="50%" style="padding:10px">
         			<table width="100%">
                    <?php
						$nql_id=$rs_hd['manager'];
						$nql=catchinfor($nql_id,"account_id","account_name","tb_account_admin");
						
						$donvi_id=$rs_hd['manager_unit'];
						$donvi=catchinfor($donvi_id,"room_id","room_name","tb_room");
					?>
                    <tr>
                    	<td width="30%"> Đơn vị quản lý</td>
                    	<td width="70%"><strong><?php echo $donvi;?></strong></td>
                    </tr>
                    
                    <tr>
                    	<td width="30%"> Người quản lý</td>
                    	<td width="70%"><strong><?php echo $nql;?></strong></td>
                     </tr>
                    <tr>
                    	<td width="30%"> Người quản lý khác</td>
                    	<td width="70%">
                        <strong>
                        <?php 
					  	$accont_id=explode(',',$rs_hd['manager_other']);
						$so_account=count($accont_id)-1;
						for($p=1;$p<=$so_account;$p++)
						{
							$tong_account=$accont_id[$p-1];
						
							$sql_account=mysql_query("select account_id,account_name from tb_account_admin where account_id='$tong_account'");
							while($rs_account=mysql_fetch_array($sql_account))
							{
								echo $rs_account['account_name'].',';
							}
						}
					  ?>
                      </strong>
                        </td>
                     </tr>                    
                    </table> 
                  </td> 
                 <td width="50%" style="padding:10px">
         			<table width="100%">
                    <tr>
                    	<?php 
						$nt_id=$rs_hd['creater'];
						$nguoitao=catchinfor($nt_id,"account_id","account_name","tb_account_admin");
						$ncn_id=$rs_hd['user_edit'];
						$nguoisua=catchinfor($ncn_id,"account_id","account_name","tb_account_admin");
						?>
                        <td width="30%">Người tạo</td>
                    	<td width="70%"> <strong><?php echo $nguoitao;?></strong></td>
                     </tr>
                    <tr>
                    	<td width="30%">Ngày tạo</td>
                    	<td width="70%"> <strong><?php echo date('d/m/Y H:i a',$rs_hd['creat_time']);?></strong></td></tr>
                 	 <tr>
                     	<td width="30%">Người cập nhật</td>
                     	<td width="70%">
                     <strong>
                     		 <?php 
								echo $nguoisua;
						?>
                    </strong>
                     </td></tr>
                    <tr>
                    	<td width="30%">Ngày cập nhật</td>
                    	<td width="70%"><strong><?php echo date('d/m/Y H:i a',$rs_hd['update_time']);?></strong></td>
                    </tr>
                   
                    </table> 
                  </td> 
                </tr> 
              </tbody> </table></td>
            <td class="c-r"></td>
          </tr>
          <tr>
            <td class="b-l"></td>
            <td class="b-c"></td>
            <td class="b-r"></td>
          </tr>
        </tbody></table>
        
       
                        </td>
						<td class="c-r"></td>
					  </tr>
					  <tr>
						<td class="b-l"></td>
						<td class="b-c"></td>
						<td class="b-r"></td>
					  </tr>
					</tbody></table>
                  
        
      